home *** CD-ROM | disk | FTP | other *** search
/ Shocking The Web CD-ROM / SHOCK_CD.ISO / pc / tutorial / casestdy / ch17_dav / clock.dcr / 00025_Clock Parent.ls < prev    next >
Encoding:
Text File  |  1996-11-12  |  1.3 KB  |  46 lines

  1. property pBigHandSprite, pLilHandSprite, pSecHandSprite
  2. global gTime, gLastCall, gMinList
  3.  
  4. on new me, minutehand, hourhand, secHand
  5.   set pBigHandSprite to minutehand
  6.   puppetSprite(pBigHandSprite, 1)
  7.   set pLilHandSprite to hourhand
  8.   puppetSprite(pLilHandSprite, 1)
  9.   set pSecHandSprite to secHand
  10.   puppetSprite(pSecHandSprite, 1)
  11.   set gLastCall to EMPTY
  12.   set gMinList to [0: "00", 12: "12", 24: "24", 36: "36", 48: "48"]
  13.   sort(gMinList)
  14.   setTime(me)
  15.   return me
  16. end
  17.  
  18. on setTime me
  19.   set gTime to the long time
  20.   if gTime = gLastCall then
  21.     exit
  22.   end if
  23.   set gLastCall to gTime
  24.   set tempID to the itemDelimiter
  25.   set the itemDelimiter to ":"
  26.   set hrs to value(item 1 of gTime)
  27.   set mins to item 2 of gTime
  28.   set temp to item 3 of gTime
  29.   set the itemDelimiter to " "
  30.   set secs to value(item 1 of temp)
  31.   set the castNum of sprite pBigHandSprite to the number of member ("BH" & mins)
  32.   set the castNum of sprite pSecHandSprite to the number of member ("SH" & secs)
  33.   setHourHand(me, hrs, value(mins))
  34.   set the itemDelimiter to tempID
  35.   puppetSound("Tick")
  36. end
  37.  
  38. on setHourHand me, hrs, mins
  39.   if hrs > 12 then
  40.     set hrs to hrs - 12
  41.   end if
  42.   set whichMin to findPosNear(gMinList, mins - 11)
  43.   set whichHourHand to "LH" & string(hrs) & getAt(gMinList, whichMin)
  44.   set the castNum of sprite pLilHandSprite to the number of member whichHourHand
  45. end
  46.